package com.itheima.service.Impl;

import com.github.pagehelper.PageHelper;
import com.itheima.domain.Student;
import com.itheima.mapper.StudentMapper;
import com.itheima.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @param
 * @return
 */
@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;
    public List<Student> findAll(int pageNum,int pageSize) throws Exception {
        PageHelper.startPage(pageNum,pageSize   );
        return studentMapper.findAll();
    }

    @Override
    public boolean add(Student student) {
        boolean flag=true;
        try {
            studentMapper.add(student);
        }catch (Exception e){
            flag=false;
        }
        return flag;
    }
    @Override
    public boolean update(Student student) {
        boolean flag=true;
        try {
            studentMapper.update(student);
        }catch (Exception e){
            flag=false;
        }
        return flag;
    }
    @Override
    public boolean delete(String number) {
        boolean flag=true;
        try {
            studentMapper.delete(number);
        }catch (Exception e){
            flag=false;
        }
        return flag;
    }
}
